<?php
declare (strict_types=1);

use think\facade\Route;
use app\admin\middleware\LoginMiddleware;
use app\admin\middleware\RuleMiddleware;

// 将资源路由put方式改成post方式
Route::rest('update', ['POST', '/:id', 'update']);
Route::rest('renew', ['POST', 'renew/:id', 'renew']);
//Route::rest('index', ['GET', 'index', 'index']);

// 路由变量规则
Route::pattern([
    'id' => '\d+',
]);

Route::get('oss', 'Login/oss');
Route::get('test2', 'Login/test2');
Route::any('test3', 'Login/test3');


Route::get('/', function () {

    return redirect(config('app.host') . '/admin/index');
});
Route::group('', function () {
    Route::get('error', 'Login/error');
    // 登录
    Route::resource('login', 'Login');

    Route::any('login/quit', 'Login/quit');


    Route::group('', function () {
        // 首页
        Route::resource('index', 'Index');

        // 《系统配置》
        // 平台规则
        Route::resource('config', 'Config');
        // 首页装修
        Route::resource('renovation', 'Renovation');
        // 首页装修操作
        Route::post('renovation/renew:id', 'Renovation/renew');
        // 个人配置
        Route::resource('personal', 'Personal');
        // 用户等级
        Route::resource('level', 'Level');


        // 账号管理
        Route::resource('account', 'Account');
        // 角色组
        Route::resource('group', 'Group');


        // 项目管理
        // 分类列表
        Route::resource('category', 'Category');
        // 分类列表
        Route::resource('label', 'Label');
        // 项目列表
        Route::resource('project', 'Project');

        Route::post('project/renew:id', 'Project/renew');
        // 项目更多视频
        Route::resource('project/video', 'ProjectVideo');

        Route::post('project/video/renew:id', 'ProjectVideo/renew');

        // 项目更多视频
        Route::resource('project/topic', 'ProjectTopic');

        // 订单列表
        Route::resource('order', 'Order');

        Route::post('order/operate', 'Order/orderOperate');

        Route::get('order/integral', 'Order/orderIntegral');

        Route::post('order/integral/operate', 'Order/orderIntegralOperate');

        Route::get('order/export', 'Order/export');


        // 用户列表
        Route::resource('user', 'User');

        Route::get('user/export', 'User/export');

        Route::post('user/renew', 'User/renew');


        // 图片上传
        Route::post('common/file', 'Common/file');

    })->middleware([LoginMiddleware::class, RuleMiddleware::class]);

});
